/**
 * 项目名：五位一体化工安全信息平台
 * 日期：    2019-11-25 19:28:38
 * Copyright (c) 2015- joysuch-版权所有
 */

package com.joysuch.wwyt.risk.entity;

import cn.zlg.common.springmvc.validate.constraints.NotNull;
import com.joysuch.wwyt.core.bean.SimpleListBean;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.dataperm.annotation.DataPermissionField;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "WWYT_RISK_DISTRICT")
@SQLDelete(sql = "update WWYT_RISK_DISTRICT set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_RISK_DISTRICT set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Proxy(lazy = false)
public class RiskDistrict implements java.io.Serializable {

    // columns START
    // ID
    private java.lang.Long id;
    // 编号
    private java.lang.String code;
    // 名称
    @NotNull(field = "区域名称")
    private java.lang.String name;
    // 区域坐标集
    private java.lang.String coordinates;
    // 备注
    private java.lang.String remark;
    // 创建人
    private java.lang.Long createBy;
    // 创建时间
    private java.util.Date createTime;
    // 更新人
    private java.lang.Long updateBy;
    // 更新时间
    private java.util.Date updateTime;
    // 删除标记
    private java.lang.String deleteFlag;
    // 组织结构代码
    private java.lang.String orgCode;
    // 租户
    private java.lang.Long tenentId;
    // 最近一次区域年份
    private java.lang.Integer lastEvaluationYear;
    // 评估状态
    private java.lang.Integer evaluationState;
    // 风险等级
    private java.lang.Integer riskLevel;
    //雪花id
    private String uniqueId;

    //风险点库id集合
    private String pointLibraryIdJson;

    //区域风险等级
    private Integer districtRiskLevel;

    //校正等级
    private Integer ruleLevel;

    //风险点列表等级
    private Integer pointsLevel;

    @ApiModelProperty("下一次评估时间")
    private Date nextEvaluationDate;

    // columns END
    //显示状态:44不显示
    private Integer state;

    //责任部门
    @DataPermissionField(sqlColumn = "responsible_dept")
    private Long responsibleDept;

    //区域类型(生产装置,储存设施,场所)
    private Long type;

    @ApiModelProperty("区域实时等级")
    private Double realTimeRiskLevel;

    @ApiModelProperty("区域固有风险评价等级")
    private Integer stableRiskLevel;

    @ApiModelProperty("责任人")
    private String responsibleUser;

    /*@ApiModelProperty("区域长")
    private Long responsibleUser;*/
    @ApiModelProperty("区域协助人员")
    private String areaHelpers;

    @ApiModelProperty("排查实时等级")
    private Integer investiageRiskLevel;


    @Column(name = "investiage_risk_level")
    public Integer getInvestiageRiskLevel() {
        return investiageRiskLevel;
    }

    public void setInvestiageRiskLevel(Integer investiageRiskLevel) {
        this.investiageRiskLevel = investiageRiskLevel;
    }

    @Column(name = "responsible_user")
    public String getResponsibleUser() {
        return responsibleUser;
    }

    public void setResponsibleUser(String responsibleUser) {
        this.responsibleUser = responsibleUser;
    }

    @Column(name = "area_helpers")
    public String getAreaHelpers() {
        return areaHelpers;
    }

    public void setAreaHelpers(String areaHelpers) {
        this.areaHelpers = areaHelpers;
    }

    @Column(name = "real_time_risk_level")
    public Double getRealTimeRiskLevel() {
        return realTimeRiskLevel;
    }

    public void setRealTimeRiskLevel(Double realTimeRiskLevel) {
        this.realTimeRiskLevel = realTimeRiskLevel;
    }

    @Column(name = "stable_risk_level")
    public Integer getStableRiskLevel() {
        return stableRiskLevel;
    }

    public void setStableRiskLevel(Integer stableRiskLevel) {
        this.stableRiskLevel = stableRiskLevel;
    }

    @Column(name = "next_evaluation_date")
    public Date getNextEvaluationDate() {
        return nextEvaluationDate;
    }

    public void setNextEvaluationDate(Date nextEvaluationDate) {
        this.nextEvaluationDate = nextEvaluationDate;
    }

    @Column(name = "rule_level")
    public Integer getRuleLevel() {
        return ruleLevel;
    }

    public void setRuleLevel(Integer ruleLevel) {
        this.ruleLevel = ruleLevel;
    }

    @Column(name = "points_level")
    public Integer getPointsLevel() {
        return pointsLevel;
    }

    public void setPointsLevel(Integer pointsLevel) {
        this.pointsLevel = pointsLevel;
    }

    @Column(name = "point_library_id_json")
    public String getPointLibraryIdJson() {
        return pointLibraryIdJson;
    }

    public void setPointLibraryIdJson(String pointLibraryIdJson) {
        this.pointLibraryIdJson = pointLibraryIdJson;
    }

    @Column(name = "district_risk_level")
    public Integer getDistrictRiskLevel() {
        return districtRiskLevel;
    }

    public void setDistrictRiskLevel(Integer districtRiskLevel) {
        this.districtRiskLevel = districtRiskLevel;
    }


    @Column(name = "unique_id")
    public String getUniqueId() {
        return uniqueId;
    }

    public void setUniqueId(String uniqueId) {
        this.uniqueId = uniqueId;
    }

    @Column(name = "state")
    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }


    public void setId(java.lang.Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public java.lang.Long getId() {
        return this.id;
    }

    @Column(name = "CODE")
    public java.lang.String getCode() {
        return this.code;
    }

    public void setCode(java.lang.String value) {
        this.code = value;
    }

    @Column(name = "NAME")
    public java.lang.String getName() {
        return this.name;
    }

    public void setName(java.lang.String value) {
        this.name = value;
    }

    @Column(name = "COORDINATES", length = 1000)
    public java.lang.String getCoordinates() {
        return this.coordinates;
    }

    public void setCoordinates(java.lang.String value) {
        this.coordinates = value;
    }

    @Column(name = "REMARK", length = 200)
    public java.lang.String getRemark() {
        return this.remark;
    }

    public void setRemark(java.lang.String value) {
        this.remark = value;
    }

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public java.lang.Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(java.lang.Long value) {
        this.createBy = value;
    }

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.util.Date value) {
        this.createTime = value;
    }

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public java.lang.Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(java.lang.Long value) {
        this.updateBy = value;
    }

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.util.Date value) {
        this.updateTime = value;
    }

    @Column(name = "DELETE_FLAG", length = 2)
    public java.lang.String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(java.lang.String value) {
        this.deleteFlag = value;
    }

    @Column(name = "ORG_CODE", length = 100)
    public java.lang.String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(java.lang.String value) {
        this.orgCode = value;
    }

    @Column(name = "TENENT_ID")
    public java.lang.Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(java.lang.Long value) {
        this.tenentId = value;
    }

    @Column(name = "last_evaluation_year")
    public java.lang.Integer getLastEvaluationYear() {
        return this.lastEvaluationYear;
    }

    public void setLastEvaluationYear(java.lang.Integer value) {
        this.lastEvaluationYear = value;
    }

    @Column(name = "evaluation_state")
    public java.lang.Integer getEvaluationState() {
        return this.evaluationState;
    }

    public void setEvaluationState(java.lang.Integer value) {
        this.evaluationState = value;
    }

    @Column(name = "risk_level")
    public java.lang.Integer getRiskLevel() {
        return this.riskLevel;
    }

    public void setRiskLevel(java.lang.Integer value) {
        this.riskLevel = value;
    }

    private RiskDistrictEvaluation riskDistrictEvaluation;

    @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @JoinColumn(name = "last_evaluation_id")
    public RiskDistrictEvaluation getRiskDistrictEvaluation() {
        return this.riskDistrictEvaluation;
    }

    public void setRiskDistrictEvaluation(RiskDistrictEvaluation riskDistrictEvaluation) {
        this.riskDistrictEvaluation = riskDistrictEvaluation;
    }

    public Long getType() {
        return type;
    }

    public void setType(Long type) {
        this.type = type;
    }

    private Set<RiskPoint> riskPoints = new LinkedHashSet<>(0);

    @OneToMany(mappedBy = "riskDistrict", fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    public Set<RiskPoint> getRiskPoints() {
        return this.riskPoints;
    }

    @Column(name = "responsible_dept")
    public Long getResponsibleDept() {
        return responsibleDept;
    }

    public void setResponsibleDept(Long responsibleDept) {
        this.responsibleDept = responsibleDept;
    }

    public void setRiskPoints(Set<RiskPoint> riskPoints) {
        this.riskPoints = riskPoints;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("code", getCode())
                .append("name", getName()).append("coordinates", getCoordinates()).append("remark", getRemark())
                .append("createBy", getCreateBy()).append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime())
                .append("deleteFlag", getDeleteFlag()).append("orgCode", getOrgCode()).append("tenentId", getTenentId())
                .append("lastEvaluationYear", getLastEvaluationYear()).append("evaluationState", getEvaluationState())
                .append("riskLevel", getRiskLevel())
                .append("type", getType()).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof RiskDistrict == false)
            return false;
        if (this == obj)
            return true;
        RiskDistrict other = (RiskDistrict) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
